home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / sound_routines.s < prev    next >
Text File  |  2004-01-02  |  16KB  |  889 lines

  1.  
  2. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3. ;        sound channel I sub routines
  4. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5.  
  6.         cnop    0,4
  7. sound_I_0:    tst.b    sound_I_onf_master
  8.         bne.s    sound_I_0_exit
  9.  
  10.         move.b    d6,(a2,d7.l)            ;$ff10.
  11.         move.b    #1,sound_I_f_envelope
  12. sound_I_0_exit:    rts
  13.  
  14.         cnop    0,4
  15. sound_I_1:    tst.b    sound_I_onf_master
  16.         bne.s    sound_I_duty_exit
  17.  
  18.         move.b    d6,(a2,d7.l)            ;$ff11.
  19.  
  20.         and.b    #%11000000,d6
  21.         cmp.b    old_sound_I_duty,d6
  22.         beq.w    sound_I_duty_exit
  23.  
  24.         move.b    d6,old_sound_I_duty
  25.  
  26.         movem.l    d0-d3/a0-a2,-(SP)
  27.  
  28.         move.l    ahi_base,a6
  29.         moveq.l    #0,d0
  30.         move.l    ahi_audio_ctrl,a2
  31.         jsr    AHI_UnloadSound(a6)
  32.  
  33.         move.l    smpl_info_I,a0
  34.         moveq.l    #0,d7
  35.         move.b    d6,d7
  36.         lsr.b    #6,d7
  37.         lea    smpl_mem_1,a1
  38.         move.l    (a1,d7.w*4),ahisi_Address(a0)    ;address.
  39.  
  40.         moveq.l    #0,d0                ;sample number.
  41.         move.l    #AHIST_SAMPLE,d1        ;type.
  42.         move.l    smpl_info_I,a0            ;info field.
  43.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  44.         jsr    AHI_LoadSound(a6)
  45.  
  46.         moveq.l    #0,d0                ;channel.
  47.         moveq.l    #0,d1                ;sample.
  48.         moveq.l    #0,d2                ;offset.
  49.         move.l    #8*512,d3            ;size (full).
  50.  
  51.                 moveq.l #1,d4                           ;new faster variant
  52.  
  53. ;        moveq.l    #0,d4
  54. ;        bset    #AHISB_IMM,d4            ;flags.
  55.         move.l    ahi_audio_ctrl,a2
  56.         jsr    AHI_SetSound(a6)
  57.  
  58.         move.l    #2048,d2
  59.         move.l    #131072,d1
  60.         sub.l    sound_I_f,d2
  61.         divu.l    d2,d1
  62.         lsl.l    #3,d1
  63.         and.l    #%111111111111111111,d1
  64.  
  65.         moveq.l    #0,d0
  66.  
  67.                 moveq.l #1,d2
  68.  
  69. ;        moveq.l    #0,d2
  70. ;        bset    #AHISB_IMM,d2
  71.         move.l    ahi_audio_ctrl,a2
  72.         jsr    AHI_SetFreq(a6)
  73.  
  74.         moveq.l    #0,d0
  75.         moveq.l    #0,d1
  76.         tst.l    sound_I_status
  77.         bne.s    no_s_I_addz
  78.         move.l    sound_I_v,d1
  79. no_s_I_addz:    move.l    sound_I_pan,d2
  80.  
  81.                 moveq.l #1,d3
  82.  
  83. ;        moveq.l    #0,d3
  84. ;        bset    #AHISB_IMM,d3
  85.         move.l    ahi_audio_ctrl,a2
  86.         jsr    AHI_SetVol(a6)
  87.  
  88.         movem.l    (SP)+,d0-d3/a0-a2
  89.  
  90. sound_I_duty_exit:
  91.         rts
  92.  
  93.         cnop    0,4
  94. sound_I_2:    tst.b    sound_I_onf_master
  95.         bne.s    sound_I_2_exit
  96.  
  97.         move.b    d6,(a2,d7.l)            ;$ff12.
  98.  
  99.         movem.l    d0-d3/a0-a2,-(SP)
  100.  
  101.         moveq.l    #0,d7
  102.         move.b    d6,d7
  103.         lsr.b    #4,d7
  104.         lea    sound_env_volumes,a6
  105.         move.l    (a6,d7.w*4),sound_I_v
  106.  
  107.         move.l    ahi_base,a6
  108.         moveq.l    #0,d0
  109.         moveq.l    #0,d1
  110.         tst.l    sound_I_status
  111.         bne.s    no_s_I_addx
  112.         move.l    sound_I_v,d1
  113. no_s_I_addx:    move.l    sound_I_pan,d2
  114.  
  115.                 moveq.l #1,d3
  116.  
  117. ;        moveq.l    #0,d3
  118. ;        bset    #AHISB_IMM,d3
  119.         move.l    ahi_audio_ctrl,a2
  120.         jsr    AHI_SetVol(a6)
  121.  
  122.         move.b    #1,sound_I_v_envelope
  123.  
  124.         movem.l    (SP)+,d0-d3/a0-a2
  125. sound_I_2_exit:    rts
  126.  
  127.         cnop    0,4
  128. sound_I_3:    tst.b    sound_I_onf_master
  129.         bne.s    sound_I_3_exit
  130.  
  131.         move.b    d6,sound_I_fl            ;$ff13.
  132.  
  133.         movem.l    d0-d2/a0-a2,-(SP)
  134.  
  135.         move.l    #2048,d2
  136.         move.l    #131072,d1
  137.         sub.l    sound_I_f,d2
  138.         divu.l    d2,d1
  139.         lsl.l    #3,d1
  140.         and.l    #%111111111111111111,d1
  141.  
  142.         move.l    ahi_base,a6
  143.         moveq.l    #0,d0
  144.  
  145.                 moveq.l #1,d2
  146.  
  147. ;        moveq.l    #0,d2
  148. ;        bset    #AHISB_IMM,d2
  149.         move.l    ahi_audio_ctrl,a2
  150.         jsr    AHI_SetFreq(a6)
  151.  
  152.         movem.l    (SP)+,d0-d2/a0-a2
  153. sound_I_3_exit:    rts
  154.  
  155.         cnop    0,4
  156. sound_I_4:    tst.b    sound_I_onf_master
  157.         bne.s    sound_I_4_exit
  158.  
  159.         movem.l    d0-d2/a0-a2,-(SP)        ;$ff14.
  160.  
  161.         move.l    ahi_base,a6
  162.  
  163.         move.b    d6,d0
  164.         and.b    #%111,d6
  165.         and.b    #%01000000,d0
  166.         move.b    d6,sound_I_fh
  167.         move.b    d0,(a2,d7.l)
  168.  
  169.         move.l    #2048,d2
  170.         move.l    #131072,d1
  171.         sub.l    sound_I_f,d2
  172.         divu.l    d2,d1
  173.         lsl.l    #3,d1
  174.         and.l    #%111111111111111111,d1
  175.  
  176.         moveq.l    #0,d0
  177.  
  178.                 moveq.l #1,d2
  179.  
  180. ;        moveq.l    #0,d2
  181. ;        bset    #AHISB_IMM,d2
  182.         move.l    ahi_audio_ctrl,a2
  183.         jsr    AHI_SetFreq(a6)
  184.  
  185.         movem.l    (SP)+,d0-d2/a0-a2
  186. sound_I_4_exit:    rts
  187.  
  188. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  189. ;        sound channel II sub routines
  190. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  191.  
  192.         cnop    0,4
  193. sound_II_1:    tst.b    sound_II_onf_master
  194.         bne.s    sound_II_duty_exit
  195.  
  196.         move.b    d6,(a2,d7.l)            ;$ff16.
  197.  
  198.         and.b    #%11000000,d6
  199.         cmp.b    old_sound_II_duty,d6
  200.         beq.w    sound_II_duty_exit
  201.  
  202.         move.b    d6,old_sound_II_duty
  203.  
  204.         movem.l    d0-d3/a0-a2,-(SP)
  205.  
  206.         move.l    ahi_base,a6
  207.         moveq.l    #1,d0
  208.         move.l    ahi_audio_ctrl,a2
  209.         jsr    AHI_UnloadSound(a6)
  210.  
  211.         move.l    smpl_info_II,a0
  212.         moveq.l    #0,d7
  213.         move.b    d6,d7
  214.         lsr.b    #6,d7
  215.         lea    smpl_mem_1,a1
  216.         move.l    (a1,d7.w*4),ahisi_Address(a0)    ;address.
  217.  
  218.         moveq.l    #1,d0                ;sample number.
  219.         move.l    #AHIST_SAMPLE,d1        ;type.
  220.         move.l    smpl_info_II,a0            ;info field.
  221.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  222.         jsr    AHI_LoadSound(a6)
  223.  
  224.         moveq.l    #1,d0                ;channel.
  225.         moveq.l    #1,d1                ;sample.
  226.         moveq.l    #0,d2                ;offset.
  227.         move.l    #8*512,d3            ;size (full).
  228.  
  229.                 moveq.l #1,d4
  230.  
  231. ;        moveq.l    #0,d4
  232. ;        bset    #AHISB_IMM,d4            ;flags.
  233.         move.l    ahi_audio_ctrl,a2
  234.         jsr    AHI_SetSound(a6)
  235.  
  236.         move.l    #2048,d2
  237.         move.l    #131072,d1
  238.         sub.l    sound_II_f,d2
  239.         divu.l    d2,d1
  240.         lsl.l    #3,d1
  241.         and.l    #%111111111111111111,d1
  242.  
  243.         moveq.l    #1,d0
  244.  
  245.                 moveq.l #1,d2
  246.  
  247. ;        moveq.l    #0,d2
  248. ;        bset    #AHISB_IMM,d2
  249.         move.l    ahi_audio_ctrl,a2
  250.         jsr    AHI_SetFreq(a6)
  251.  
  252.         moveq.l    #1,d0
  253.         moveq.l    #0,d1
  254.         tst.l    sound_II_status
  255.         bne.s    no_s_II_addz
  256.         move.l    sound_II_v,d1
  257. no_s_II_addz:    move.l    sound_II_pan,d2
  258.  
  259.                 moveq.l #1,d3
  260.  
  261. ;        moveq.l    #0,d3
  262. ;        bset    #AHISB_IMM,d3
  263.         move.l    ahi_audio_ctrl,a2
  264.         jsr    AHI_SetVol(a6)
  265.  
  266.         movem.l    (SP)+,d0-d3/a0-a2
  267.  
  268. sound_II_duty_exit:
  269.         rts
  270.  
  271.         cnop    0,4
  272. sound_II_2:    tst.b    sound_II_onf_master
  273.         bne.s    sound_II_2_exit
  274.  
  275.         move.b    d6,(a2,d7.l)            ;$ff17.
  276.  
  277.         movem.l    d0-d3/a0-a2,-(SP)
  278.  
  279.         moveq.l    #0,d7
  280.         move.b    d6,d7
  281.         lsr.b    #4,d7
  282.         lea    sound_env_volumes,a6
  283.         move.l    (a6,d7.w*4),sound_II_v
  284.  
  285.         move.l    ahi_base,a6
  286.         moveq.l    #1,d0
  287.         moveq.l    #0,d1
  288.         tst.l    sound_II_status
  289.         bne.s    no_s_II_addx
  290.         move.l    sound_II_v,d1
  291. no_s_II_addx:    move.l    sound_II_pan,d2
  292.  
  293.                 moveq.l #1,d3
  294.  
  295. ;        moveq.l    #0,d3
  296. ;        bset    #AHISB_IMM,d3
  297.         move.l    ahi_audio_ctrl,a2
  298.         jsr    AHI_SetVol(a6)
  299.  
  300.         move.b    #1,sound_II_v_envelope
  301.  
  302.         movem.l    (SP)+,d0-d3/a0-a2
  303. sound_II_2_exit:rts
  304.  
  305.         cnop    0,4
  306. sound_II_3:    tst.b    sound_II_onf_master
  307.         bne.s    sound_II_3_exit
  308.  
  309.         move.b    d6,sound_II_fl            ;$ff18.
  310.  
  311.         movem.l    d0-d2/a0-a2,-(SP)
  312.  
  313.         move.l    #131072,d1
  314.         move.l    #2048,d2
  315.         sub.l    sound_II_f,d2
  316.         divu.l    d2,d1
  317.         lsl.l    #3,d1
  318.         and.l    #%111111111111111111,d1
  319.  
  320.         move.l    ahi_base,a6
  321.         moveq.l    #1,d0
  322.  
  323.                 moveq.l #1,d2
  324.  
  325. ;        moveq.l    #0,d2
  326. ;        bset    #AHISB_IMM,d2
  327.         move.l    ahi_audio_ctrl,a2
  328.         jsr    AHI_SetFreq(a6)
  329.  
  330.         movem.l    (SP)+,d0-d2/a0-a2
  331. sound_II_3_exit:rts
  332.  
  333.         cnop    0,4
  334. sound_II_4:    tst.b    sound_II_onf_master
  335.         bne.s    sound_II_4_exit
  336.  
  337.         movem.l    d0-d2/a0-a2,-(SP)        ;$ff19.
  338.  
  339.         move.l    ahi_base,a6
  340.  
  341.         move.b    d6,d0
  342.         and.b    #%111,d6
  343.         and.b    #%01000000,d0
  344.         move.b    d6,sound_II_fh
  345.         move.b    d0,(a2,d7.l)
  346.  
  347.         move.l    #131072,d1
  348.         move.l    #2048,d2
  349.         sub.l    sound_II_f,d2
  350.         divu.l    d2,d1
  351.         lsl.l    #3,d1
  352.         and.l    #%111111111111111111,d1
  353.  
  354.         moveq.l    #1,d0
  355.  
  356.                 moveq.l #1,d2
  357.  
  358. ;        moveq.l    #0,d2
  359. ;        bset    #AHISB_IMM,d2
  360.         move.l    ahi_audio_ctrl,a2
  361.         jsr    AHI_SetFreq(a6)
  362.  
  363.         movem.l    (SP)+,d0-d2/a0-a2
  364. sound_II_4_exit:rts
  365.  
  366. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  367. ;        sound channel III sub routines
  368. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  369.  
  370.         cnop    0,4
  371. sound_III_0:    tst.b    sound_III_onf_master
  372.         bne.s    sound_III_0_exit
  373.  
  374.         and.b    #%10000000,d6            ;$ff1a.
  375.         move.b    d6,(a2,d7.l)
  376.  
  377.         bne.s    sound_III_on
  378.  
  379. sound_III_off:    movem.l    d0-d3/a0-a2,-(SP)
  380.  
  381.         move.b    #1,sound_III_onf_bit
  382.  
  383.         move.l    ahi_base,a6
  384.         moveq.l    #2,d0
  385.         moveq.l    #0,d1
  386.         move.l    sound_III_pan,d2
  387.  
  388.                 moveq.l #1,d3
  389.  
  390. ;        moveq.l    #0,d3
  391. ;        bset    #AHISB_IMM,d3
  392.         move.l    ahi_audio_ctrl,a2
  393.         jsr    AHI_SetVol(a6)
  394.  
  395.         movem.l    (SP)+,d0-d3/a0-a2
  396. sound_III_0_exit:
  397.         rts
  398.  
  399.         cnop    0,4
  400. sound_III_on:    clr.b    sound_III_onf_bit
  401.  
  402.         movem.l    d0-d3/a0-a2,-(SP)
  403.  
  404.         move.l    ahi_base,a6
  405.         moveq.l    #2,d0
  406.         moveq.l    #0,d1
  407.         tst.l    sound_III_status
  408.         bne.s    no_s_III_addq
  409.         move.l    sound_III_v,d1
  410. no_s_III_addq:    move.l    sound_III_pan,d2
  411.  
  412.                 moveq.l #1,d3
  413.  
  414. ;        moveq.l    #0,d3
  415. ;        bset    #AHISB_IMM,d3
  416.         move.l    ahi_audio_ctrl,a2
  417.         jsr    AHI_SetVol(a6)
  418.  
  419.         movem.l    (SP)+,d0-d3/a0-a2
  420.         rts
  421.  
  422.         cnop    0,4
  423. sound_III_1:    tst.b    sound_III_onf_master
  424.         bne.s    sound_III_1_exit
  425.  
  426.         move.b    d6,(a2,d7.l)            ;$ff1b.
  427. sound_III_1_exit:
  428.         rts
  429.  
  430.         cnop    0,4
  431. sound_III_2:    tst.b    sound_III_onf_master
  432.         bne.s    sound_III_2_exit
  433.  
  434.         and.b    #%01100000,d6            ;$ff1c.
  435.         move.b    d6,(a2,d7.l)
  436.  
  437.         movem.l    d0-d3/a0-a2,-(SP)
  438.  
  439.         lsr.b    #3,d6
  440.         and.l    #%1100,d6
  441.         lea    sound_III_vol,a1
  442.         move.l    (a1,d6.w),sound_III_v
  443.  
  444.         move.l    ahi_base,a6
  445.         moveq.l    #2,d0
  446.         moveq.l    #0,d1
  447.         tst.l    sound_III_status
  448.         bne.s    no_s_III_addp
  449.         move.l    sound_III_v,d1
  450. no_s_III_addp:    move.l    sound_III_pan,d2
  451.  
  452.                 moveq.l #1,d3
  453.  
  454. ;        moveq.l    #0,d3
  455. ;        bset    #AHISB_IMM,d3
  456.         move.l    ahi_audio_ctrl,a2
  457.         jsr    AHI_SetVol(a6)
  458.  
  459.         movem.l    (SP)+,d0-d3/a0-a2
  460. sound_III_2_exit:
  461.         rts
  462.  
  463.         cnop    0,4
  464. sound_III_3:    tst.b    sound_III_onf_master
  465.         bne.s    sound_III_3_exit
  466.  
  467.         move.b    d6,sound_III_fl            ;$ff1d.
  468.  
  469.         movem.l    d0-d2/a0-a2,-(SP)
  470.  
  471.         move.l    #131072/2,d1
  472.         move.l    #2048,d2
  473.         sub.l    sound_III_f,d2
  474.         divu.l    d2,d1
  475.         lsl.l    #5,d1
  476.         and.l    #%111111111111111111,d1
  477.  
  478.         move.l    ahi_base,a6
  479.         moveq.l    #2,d0
  480.  
  481.                 moveq.l #1,d2
  482.  
  483. ;        moveq.l    #0,d2
  484. ;        bset    #AHISB_IMM,d2
  485.         move.l    ahi_audio_ctrl,a2
  486.         jsr    AHI_SetFreq(a6)
  487.  
  488.         movem.l    (SP)+,d0-d2/a0-a2
  489. sound_III_3_exit:
  490.         rts
  491.  
  492.         cnop    0,4
  493. sound_III_4:    tst.b    sound_III_onf_master
  494.         bne.s    sound_III_4_exit
  495.  
  496.         movem.l    d0-d2/a0-a2,-(SP)        ;$ff1e.
  497.  
  498.         move.b    d6,d0
  499.         and.b    #%111,d6
  500.         and.b    #%01000000,d0
  501.         move.b    d6,sound_III_fh
  502.         move.b    d0,(a2,d7.l)
  503.  
  504.         move.l    #131072,d1
  505.         move.l    #2048,d2
  506.         sub.l    sound_III_f,d2
  507.         divu.l    d2,d1
  508.         lsl.l    #5,d1
  509.         and.l    #%111111111111111111,d1
  510.  
  511.         move.l    ahi_base,a6
  512.         moveq.l    #2,d0
  513.  
  514.                 moveq.l #1,d2
  515.  
  516. ;        moveq.l    #0,d2
  517. ;        bset    #AHISB_IMM,d2
  518.         move.l    ahi_audio_ctrl,a2
  519.         jsr    AHI_SetFreq(a6)
  520.  
  521.         movem.l    (SP)+,d0-d2/a0-a2
  522. sound_III_4_exit:
  523.         rts
  524.  
  525.         cnop    0,4
  526. copy_snd_data:    move.b    d6,(a2,d7.l)            ;copy the byte
  527.                             ;to gb ram.
  528.         sub.w    #$ff30,d7
  529.         move.l    sound_III_lst,a6
  530.         and.l    #$ff,d6
  531.         move.w    (a6,d6.w*2),d6
  532.  
  533.         move.l    smpl_III_mem,a6
  534.         move.w    d6,(a6,d7.w*2)            ;expand the steps.
  535.         rts
  536.  
  537. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  538. ;        sound channel IV sub routines
  539. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  540.  
  541.         cnop    0,4
  542. sound_IV_1:    tst.b    sound_IV_onf_master
  543.         bne.s    sound_IV_1_exit
  544.  
  545.         move.b    d6,(a2,d7.l)            ;$ff20.
  546. sound_IV_1_exit:rts
  547.  
  548.         cnop    0,4
  549. sound_IV_2:    tst.b    sound_IV_onf_master
  550.         bne.s    sound_IV_2_exit
  551.  
  552.         move.b    d6,(a2,d7.l)            ;$ff21.
  553.  
  554.         movem.l    d0-d3/a0-a2,-(SP)
  555.  
  556.         moveq.l    #0,d7
  557.         move.b    d6,d7
  558.         lsr.b    #4,d7
  559.         lea    sound_env_volumes,a6
  560.         move.l    (a6,d7.w*4),sound_IV_v
  561.  
  562.         move.l    ahi_base,a6
  563.         moveq.l    #3,d0
  564.         moveq.l    #0,d1
  565.         tst.l    sound_IV_status
  566.         bne.s    no_s_IV_addx
  567.         move.l    sound_IV_v,d1
  568. no_s_IV_addx:    move.l    sound_IV_pan,d2
  569.  
  570.                 moveq.l #1,d3
  571.  
  572. ;        moveq.l    #0,d3
  573. ;        bset    #AHISB_IMM,d3
  574.         move.l    ahi_audio_ctrl,a2
  575.         jsr    AHI_SetVol(a6)
  576.  
  577.         move.b    #1,sound_I_v_envelope
  578.  
  579.         movem.l    (SP)+,d0-d3/a0-a2
  580. sound_IV_2_exit:rts
  581.  
  582.         cnop    0,4
  583. sound_IV_3:    tst.b    sound_IV_onf_master
  584.         bne.s    sound_IV_3_exit
  585.  
  586.         move.b    d6,(a2,d7.l)            ;$ff22.
  587.  
  588.         movem.l    d0-d3/a0-a2,-(SP)
  589.  
  590.         move.b    d6,d7
  591.  
  592.         lea    sound_4_freq_table,a0
  593.         and.l    #%111,d6
  594.         move.l    (a0,d6.w*4),d1
  595.  
  596.         lsr.b    #4,d7
  597.         and.b    #%1111,d7
  598.         addq.b    #1,d7
  599.         lsr.l    d7,d1
  600.  
  601.         move.l    ahi_base,a6
  602.         moveq.l    #3,d0
  603.  
  604.                 moveq.l #1,d2
  605.  
  606. ;        moveq.l    #0,d2
  607. ;        bset    #AHISB_IMM,d2
  608.         move.l    ahi_audio_ctrl,a2
  609.         jsr    AHI_SetFreq(a6)
  610.  
  611.         movem.l    (SP)+,d0-d3/a0-a2
  612. sound_IV_3_exit:rts
  613.  
  614.         cnop    0,4
  615. sound_IV_4:    tst.b    sound_IV_onf_master
  616.         bne.s    sound_IV_4_exit
  617.  
  618.         and.b    #%01000000,d6            ;$ff23.
  619.         move.b    d6,(a2,d7.l)
  620.  
  621.         beq.s    sound_IV_4_kicked
  622.  
  623.         movem.l    d0-d3/a0-a2,-(SP)
  624.  
  625.         move.l    ahi_base,a6
  626.         moveq.l    #3,d0
  627.         moveq.l    #0,d1
  628.         move.l    sound_IV_pan,d2
  629.  
  630.                 moveq.l #1,d3
  631.  
  632. ;        moveq.l    #0,d3
  633. ;        bset    #AHISB_IMM,d3
  634.         move.l    ahi_audio_ctrl,a2
  635.         jsr    AHI_SetVol(a6)
  636.  
  637.         movem.l    (SP)+,d0-d3/a0-a2
  638. sound_IV_4_exit:rts
  639.  
  640. sound_IV_4_kicked:
  641.         movem.l    d0-d3/a0-a2,-(SP)
  642.  
  643.         move.l    ahi_base,a6
  644.         moveq.l    #3,d0
  645.         moveq.l    #0,d1
  646.         tst.l    sound_IV_status
  647.         bne.s    no_s_IV_addt
  648.         move.l    sound_IV_v,d1
  649. no_s_IV_addt:    move.l    sound_IV_pan,d2
  650.  
  651.                 moveq.l #1,d3
  652.  
  653. ;        moveq.l    #0,d3
  654. ;        bset    #AHISB_IMM,d3
  655.         move.l    ahi_audio_ctrl,a2
  656.         jsr    AHI_SetVol(a6)
  657.  
  658.         movem.l    (SP)+,d0-d3/a0-a2
  659.         rts
  660.  
  661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  662. ;        sound control routines
  663. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  664.  
  665.         cnop    0,4
  666. sound_V_0:    move.b    d6,(a2,d7.l)            ;$ff24.
  667.  
  668. ;        move.b    d6,sound_master_bits
  669.  
  670.         move.b    1(a2,d7.l),d6
  671.  
  672. sound_V_1:    move.b    d6,(a2,d7.l)            ;$ff25.
  673.  
  674.         movem.l    d0-d3/a0-a2,-(SP)
  675.  
  676.         lea    pan_table,a6
  677.         lea    onf_table,a2
  678.         moveq.l    #0,d7
  679.  
  680.         move.b    d6,d7
  681.         and.b    #%10001,d7
  682.         move.b    d7,d0
  683.         lsr.b    #3,d7
  684.         and.b    #%1,d0
  685.         or.b    d0,d7
  686.         move.l    (a6,d7.w*4),sound_I_pan
  687.         move.b    (a2,d7.w),sound_I_onf
  688.  
  689.         move.b    d6,d7
  690.         and.b    #%100010,d7
  691.         lsr.b    #1,d7
  692.         move.b    d7,d0
  693.         lsr.b    #3,d7
  694.         and.b    #%1,d0
  695.         or.b    d0,d7
  696.         move.l    (a6,d7.w*4),sound_II_pan
  697.         move.b    (a2,d7.w),sound_II_onf
  698.  
  699.         move.b    d6,d7
  700.         and.b    #%1000100,d7
  701.         lsr.b    #2,d7
  702.         move.b    d7,d0
  703.         lsr.b    #3,d7
  704.         and.b    #%1,d0
  705.         or.b    d0,d7
  706.         move.l    (a6,d7.w*4),sound_III_pan
  707.         move.b    (a2,d7.w),sound_III_onf
  708.  
  709.         and.l    #%10001000,d6
  710.         lsr.b    #3,d6
  711.         move.b    d6,d0
  712.         lsr.b    #3,d6
  713.         and.b    #%1,d0
  714.         or.b    d0,d6
  715.         move.l    (a6,d6.w*4),sound_IV_pan
  716.         move.b    (a2,d6.w),sound_IV_onf
  717.  
  718. sounds_on_jmp:    move.l    ahi_base,a6
  719.  
  720.         tst.b    snd_chnlI
  721.         bne.s    no_I_vc
  722.  
  723.         moveq.l    #0,d0
  724.         moveq.l    #0,d1
  725.         tst.l    sound_I_status
  726.         bne.s    no_s_I_add
  727.         move.l    sound_I_v,d1
  728. no_s_I_add:    move.l    sound_I_pan,d2
  729.  
  730.                 moveq.l #1,d3
  731.  
  732. ;        moveq.l    #0,d3
  733. ;        bset    #AHISB_IMM,d3
  734.         move.l    ahi_audio_ctrl,a2
  735.         jsr    AHI_SetVol(a6)
  736.  
  737. no_I_vc:    tst.b    snd_chnlII
  738.         bne.s    no_II_vc
  739.  
  740.         moveq.l    #1,d0
  741.         moveq.l    #0,d1
  742.         tst.l    sound_II_status
  743.         bne.s    no_s_II_add
  744.         move.l    sound_II_v,d1
  745. no_s_II_add:    move.l    sound_II_pan,d2
  746.  
  747.                 moveq.l #1,d3
  748.  
  749. ;        moveq.l    #0,d3
  750. ;        bset    #AHISB_IMM,d3
  751.         move.l    ahi_audio_ctrl,a2
  752.         jsr    AHI_SetVol(a6)
  753.  
  754. no_II_vc:    tst.b    snd_chnlIII
  755.         bne.s    no_III_vc
  756.  
  757.         moveq.l    #2,d0
  758.         moveq.l    #0,d1
  759.         tst.l    sound_III_status
  760.         bne.s    no_s_III_add
  761.         move.l    sound_III_v,d1
  762. no_s_III_add:    move.l    sound_III_pan,d2
  763.  
  764.                 moveq.l #1,d3
  765.  
  766. ;        moveq.l    #0,d3
  767. ;        bset    #AHISB_IMM,d3
  768.         move.l    ahi_audio_ctrl,a2
  769.         jsr    AHI_SetVol(a6)
  770.  
  771. no_III_vc:    tst.b    snd_chnlIV
  772.         bne.s    no_IV_vc
  773.  
  774.         moveq.l    #3,d0
  775.         moveq.l    #0,d1
  776.         tst.l    sound_IV_status
  777.         bne.s    no_s_IV_add
  778.         move.l    sound_IV_v,d1
  779. no_s_IV_add:    move.l    sound_IV_pan,d2
  780.  
  781.                 moveq.l #1,d3
  782.  
  783. ;        moveq.l    #0,d3
  784. ;        bset    #AHISB_IMM,d3
  785.         move.l    ahi_audio_ctrl,a2
  786.         jsr    AHI_SetVol(a6)
  787.  
  788. no_IV_vc:    movem.l    (SP)+,d0-d3/a0-a2
  789.         rts
  790.  
  791.         cnop    0,4
  792. sound_V_2:    and.b    #%10001111,d6            ;$ff26.
  793.         move.b    d6,(a2,d7.l)
  794.  
  795.         movem.l    d0-d3/a0-a2,-(SP)
  796.  
  797.         clr.b    sound_I_onf_master
  798.         clr.b    sound_II_onf_master
  799.         clr.b    sound_III_onf_master
  800.         clr.b    sound_IV_onf_master
  801.  
  802.         btst    #7,d6
  803.         bne.w    sounds_on_jmp
  804.  
  805. sound_V_off:    move.l    ahi_base,a6
  806.  
  807.         moveq.l    #0,d0
  808.         moveq.l    #0,d1
  809.         move.l    sound_I_pan,d2
  810.  
  811.                 moveq.l #1,d3
  812.  
  813. ;        moveq.l    #0,d3
  814. ;        bset    #AHISB_IMM,d3
  815.         move.l    ahi_audio_ctrl,a2
  816.         jsr    AHI_SetVol(a6)
  817.  
  818.         moveq.l    #1,d0
  819.         moveq.l    #0,d1
  820.         move.l    sound_II_pan,d2
  821.  
  822.                 moveq.l #1,d3
  823.  
  824. ;        moveq.l    #0,d3
  825. ;        bset    #AHISB_IMM,d3
  826.         move.l    ahi_audio_ctrl,a2
  827.         jsr    AHI_SetVol(a6)
  828.  
  829.         moveq.l    #2,d0
  830.         moveq.l    #0,d1
  831.         move.l    sound_III_pan,d2
  832.  
  833.                 moveq.l #1,d3
  834.  
  835. ;        moveq.l    #0,d3
  836. ;        bset    #AHISB_IMM,d3
  837.         move.l    ahi_audio_ctrl,a2
  838.         jsr    AHI_SetVol(a6)
  839.  
  840.         moveq.l    #3,d0
  841.         moveq.l    #0,d1
  842.         move.l    sound_IV_pan,d2
  843.  
  844.                 moveq.l #1,d3
  845.  
  846. ;        moveq.l    #0,d3
  847. ;        bset    #AHISB_IMM,d3
  848.         move.l    ahi_audio_ctrl,a2
  849.         jsr    AHI_SetVol(a6)
  850.  
  851.         move.b    d3,sound_I_onf_master
  852.         move.b    d3,sound_II_onf_master
  853.         move.b    d3,sound_III_onf_master
  854.         move.b    d3,sound_IV_onf_master
  855.  
  856.  
  857. ;        move.b    #1,sound_I_onf_master
  858. ;        move.b    #1,sound_II_onf_master
  859. ;        move.b    #1,sound_III_onf_master
  860. ;        move.b    #1,sound_IV_onf_master
  861.  
  862.         move.l    gb_memory,a0            ;reset the sound registers.
  863.         add.l    #$ff00,a0
  864.  
  865.         clr.b    $10(a0)
  866.         clr.b    $11(a0)
  867.         clr.b    $12(a0)
  868.         clr.b    $13(a0)
  869.         clr.b    $14(a0)
  870.  
  871.         clr.b    $16(a0)
  872.         clr.b    $17(a0)
  873.         clr.b    $18(a0)
  874.         clr.b    $19(a0)
  875.  
  876.         clr.b    $1a(a0)
  877.         clr.b    $1b(a0)
  878.         clr.b    $1c(a0)
  879.         clr.b    $1d(a0)
  880.         clr.b    $1e(a0)
  881.  
  882.         clr.b    $20(a0)
  883.         clr.b    $21(a0)
  884.         clr.b    $22(a0)
  885.         clr.b    $23(a0)
  886.  
  887.         movem.l    (SP)+,d0-d3/a0-a2
  888.         rts
  889.